package com.softeem.controller;

import com.softeem.entity.Info;
import com.softeem.entity.Staff;
import com.softeem.entity.User;
import com.softeem.entity.WorkOrder;
import com.softeem.service.StaffService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RequestMapping("/staff")
@Controller
public class StaffController {
    @Autowired
    private StaffService staffService;

    @RequestMapping("/takeOrder")
    @ResponseBody
    public Map<String, Object> takeOrder(WorkOrder workOrder){
        Map<String, Object> result = new HashMap<>();
        result.put("state",staffService.takeOrder(workOrder));
        return result;
    }

    @RequestMapping("/login")
    @ResponseBody
    public Map<String, Object> login(@Param("staff") Staff staff, @Param("isKeep") String isKeep, @Param("req") HttpServletRequest req,@Param("resp")  HttpServletResponse resp){
        System.out.println("StaffController.login");
        Map<String, Object> result = new HashMap<>();
        result.put("state",staffService.login(staff,isKeep,req,resp));
        return result;
    }
}
